#!/usr/local/bin/sbcl --script

;;; hack manually

(defun digits (num)
  (map 'list
       #'(lambda (char) (read-from-string (string char)))
       (prin1-to-string num)))

;;;;;;;; why this solution such slow?
;(let ((ira-string-list (loop for i = 0 then (1+ i)
;     and a-list = '() then (append a-list (digits i))
;			   when (> (length a-list) 1000000)
;;;;;;;; 

(defun p40 ()
  (let ((ira-string-list (loop for i from 0 to 200000
			    append (digits i))))
    (print (reduce '* (mapcar (lambda (x) (nth x ira-string-list)) '(100 1000 10000 100000 1000000))))))

(time (p40))
